import { createStore } from 'vuex'  // 修改为使用 createStore
import kuanModule from './kuan.js'


const store = createStore({
    state: {
        
        memberuid: uni.getStorageSync('memberuid') || '',
        member: uni.getStorageSync('member') || {},
        keycode: uni.getStorageSync('keycode') || '',
    },
    mutations: {
        setMember(state, member) {
            state.member = member
            uni.setStorageSync('member', member)
        },
        setMemberUid(state, memberuid) {
            state.memberuid = memberuid
            uni.setStorageSync('memberuid', memberuid)
        },
        setKeycode(state, keycode) {
            state.keycode = keycode
            uni.setStorageSync('keycode', keycode)
        },
        updateMemberMoney(state, money) {
            if (state.member) {
                state.member.money = money
                uni.setStorageSync('member', state.member)
            }
        }
    },
    // 集成kuan模块
    modules: {
      kuan: kuanModule,
      //app: appModule
    }
    
})
//console.log('Store initialized:', store)  // 添加调试
export default store;